using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using System.Xml;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace MailSenderPro.Forms
{
    public partial class FrmMailList : Form, Util.IKaydedilebilir
    {
        public FrmMailList()
        {
            InitializeComponent();
        }

        #region IKaydedilebilir Members

        public void Save()
        {
            var liste = bndMailAlici.List.Cast<Util.MailAlici>().ToList();

            if (liste.Count > 0)
            {
                FileStream fs;
                StreamWriter sw;
                try
                {
                    string path = Path.Combine(Application.StartupPath, "mails.bin");
                    fs = new FileStream(path, FileMode.OpenOrCreate);
                    sw = new StreamWriter(fs);
                    BinaryFormatter formatla = new BinaryFormatter();

                    formatla.Serialize(fs, liste);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
        }

        #endregion

        private void FrmMailList_Load(object sender, EventArgs e)
        {
            bndMailAlici.DataSource = Util.Globals.MailList; 
        }

    }



}